Skip to content
This repository was archived by the owner on May 16, 2026. It is now read-only.

fix: support urllib3 2.6.0+ by replacing deprecated getheaders()#1

Open
AmSach wants to merge 1 commit into
masterfrom
fix-urllib3-260-fix
Open

fix: support urllib3 2.6.0+ by replacing deprecated getheaders()#1
AmSach wants to merge 1 commit into
masterfrom
fix-urllib3-260-fix

Conversation

@AmSach
Copy link
Copy Markdown
Owner

@AmSach AmSach commented May 3, 2026

Summary

urllib3 2.6.0 removed the getheaders() method in favor of the headers attribute. This causes the Kubernetes Python client to crash with AttributeError when urllib3 >= 2.6.0 is used.

Bug Description

When an API exception is raised, ApiException.__init__ calls http_resp.getheaders() which no longer exists in urllib3 >= 2.6.0. Similarly, RESTResponse.getheaders() also uses the deprecated method.

Fix

  1. RESTResponse.getheaders(): Use getattr to fall back to the headers attribute when getheaders is not available.

  2. ApiException.__init__: Use try/except to fall back to the headers attribute when getheaders raises AttributeError.

This ensures compatibility with both urllib3 < 2.6.0 and urllib3 >= 2.6.0.

Testing

  • Verified the code compiles correctly
  • The fix handles the AttributeError gracefully and falls back to headers attribute

Related Issue

Fixes kubernetes-client#2477

urllib3 2.6.0 removed getheaders() method in favor of the headers attribute.
This caused ApiException and RESTResponse.getheaders() to crash with AttributeError
when urllib3 >= 2.6.0 was used.

Fix:
- RESTResponse.getheaders(): Use getattr to fallback to headers attribute
- ApiException.__init__: Use try/except to fallback to headers attribute

Fixes kubernetes-client#2477
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kubernetes Clients breaks with urllib3 2.6.0

1 participant